
export const echartGrid = (options = {}) => {
    return {
        top: 40,
        left: 40,
        right: 80,
        bottom: 20,
        containLabel: true,
        ...options
    }
}
export const echartLegend = (legend, top = 20, position = "center") => {
    let params = {
        top,
        itemWidth: 20,
        itemHeight: 12,
        itemGap: 30,
        borderRadius: 30, // 统一设置四个角的圆角大小
        textStyle: {
            color: "#ffffff",
            fontSize: 16
        },
        data: legend
    }
    console.log(position)
    if (position == 'right') {
        params.right = 40
    } else {
        params.left = position
    }
    return params
}
export const xAxisTick = {
    show: false
}
export const xAxisline = {
    lineStyle: { color: "#456dbe" }
}
export const xAxisLabel = (rotate = 0, formatter) => {
    let params = {
        interval: 0,
        textStyle: {
            color: "#fff",
            fontSize: 12,
            padding: [12, 0, 0, 0],
        },
        rotate,
        margin: 0
    }
    if (formatter) {
        params.formatter = formatter
    }
    return params
}
export const yAxisDw = (dw) => {
    return {
        name: dw,
        nameTextStyle: {
            color: "#b3d3e5",
            fontSize: 14,
            nameLocation: "start"
        },
    }
}
export const yAxisTick = {
    show: false
}
export const yAxisline = {
    lineStyle: { color: "#456dbe" }
}
export const yAxisLabel = {
    textStyle: { fontSize: 12, color: "#fff" }
}
export const splitLine = {
    show: true,
    lineStyle: {
        color: "#456dbe",
        type: "dashed"
    }
}
export const tooltipTextColor = "#85D2FF"
export const tooltip = (option = {}) => {
    let params = {
        trigger: "axis",
        padding: 3,
        backgroundColor: "#0121c1",
        textStyle: {
            align: "left",
            color: "#85D2FF",
            height: 20,
            lineHeight: 20
        },
        axisPointer: {
            type: "shadow"
        },
        ...option
    }
    return params
}
export const dataZoomBottom = (endValue = 7) => {
    return {
        show: true,
        type: "slider",
        startValue: 0,
        endValue,
        showDetail: false,
        moveOnMouseWheel: true,
        moveOnMouseMove: true,
        zoomOnMouseWheel: false,
        borderColor: "rgba(255, 255, 255, 0.3)",
        fillerColor: 'rgba(255, 255, 255, 0.33)',
        height: 8,
        bottom: 16
    }
}
export const dataZoomRight = (yAxisIndex = [0, 1], options) => {
    return {
        type: "slider",
        showDetail: false,
        show: true,
        yAxisIndex,
        startValue: 0,
        endValue: 5,
        handleSize: 4,
        moveOnMouseWheel: true,
        moveOnMouseMove: true,
        borderColor: "rgba(255, 255, 255, 0.3)",
        fillerColor: 'rgba(255, 255, 255, 0.33)',
        top: 20,
        right: 60,
        width: 8,
        bottom: 16,
        ...options
    }
}
export const ColorOne = (params) => {
    var color;
    if (params.dataIndex % 8 == 0) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,

                    color: "#4D69E7" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#29A7FF" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 1) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,

                    color: "#85921A" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#EBC92C" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 2) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "rgba(121,241,72,0.2)" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#429B20" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 3) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "#890960" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#E5429A" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 4) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "#0779D0" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#29A7FF" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 5) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "#8D8809" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#EBC92C" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 6) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "#059913" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#429B20" // 100% 处的颜色
                }
            ]
        };
    } else if (params.dataIndex % 8 == 7) {
        color = {
            type: "linear",
            x: 0,
            y: 0,
            x2: 1,
            y2: 0,
            colorStops: [
                {
                    offset: 0,
                    color: "#0779D0" // 0% 处的颜色
                },
                {
                    offset: 1,
                    color: "#29A7FF" // 100% 处的颜色
                }
            ]
        };
    }
    return color;
}